package com.social.controller;

import com.alibaba.fastjson.JSON;
import com.social.pojo.CaseManagement;
import com.social.pojo.Ultimate;
import com.social.service.CaseManagementService;
import com.social.service.UltimateService;
import com.social.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 已核定缴费基数案件管理
 */
@Controller
@RequestMapping("caseManagement")
public class CaseManagementController {
    /**
     * CaseManagement 业务层对象
     */
    @Resource
    private CaseManagementService caseManagement;

    /**
     * 添加方法
     *
     * @param caseManagement 实体类对象
     * @return 添加状态
     */
    @RequestMapping("insert")
    @ResponseBody
    public String insert(CaseManagement caseManagement) {
        caseManagement.setStatus(0);
        int status = this.caseManagement.insertSelective(caseManagement);
        //返回状态
        JsonUtil jsonUtil = new JsonUtil();
        //设置状态
        Boolean restates = jsonUtil.getRestates(status);
        return JSON.toJSONString(restates);
    }

    /**
     * 修改方法
     *
     * @param caseManagement 实体类对象
     * @return 修改状态
     */
    @RequestMapping("update")
    @ResponseBody
    public String update(CaseManagement caseManagement) {
        int status = this.caseManagement.updateByRegistrationOfCasesId(caseManagement);
        //返回状态
        JsonUtil jsonUtil = new JsonUtil();
        //设置状态
        Boolean restates = jsonUtil.getRestates(status);
        return JSON.toJSONString(restates);
    }

    /**
     * 根据RegistrationOfCases primary key 查询
     *
     * @param id RegistrationOfCases primary key
     * @return 查询后的对象
     */
    @RequestMapping("selectById")
    @ResponseBody
    public String selectById(Integer id) {
        CaseManagement caseManagement = this.caseManagement.selectByRegistrationOfCasesId(id);
        return JSON.toJSONString(caseManagement);
    }
}
